#ifndef PROCESS_INJECTOR_IMPL_X86_H_
#define PROCESS_INJECTOR_IMPL_X86_H_


#include "tools/impl/win/x86/asm86.h"
#include <Windows.h>
#include <string>

using namespace sd::tools::asmcommand::x86;

namespace sd
{
namespace prin
{
namespace impl
{



#pragma pack(push, 1)

const void* getProcAddr( const std::string& name )
{
	HMODULE mod = LoadLibraryA("Kernel32.dll");
	const void* result = GetProcAddress(mod, name.c_str());
	FreeLibrary(mod);
	return result;
}



//	originalAddrRel - offsetof(repeater2, jmpNear_)
//			repeater( CalculateRelativAddres( (char*)place, owner_->getFunction().getMemory() ) + sizeof(jmpNear) ) );


struct inject_stub
{
	inject_stub( const void* place ):
	loadLibraryW_( CalculateRelativAddres( place, getProcAddr("LoadLibraryW") ) )
		//,closeHandle_( CalculateRelativAddres( (const char*)place + offsetof(inject_stub,inject_stub::closeHandle_), getProcAddr("CloseHandle") ) )
	{}
	const int3          int3_;
	const callNear		loadLibraryW_;
//	const pushReg<EAX>  pushEax_;
//	const callNear		closeHandle_;
	const ret           ret_;
};


#pragma pack(pop)

}//sd
}//prin
}//impl



#endif//PROCESS_INJECTOR_IMPL_X86_H_
